<template>
  <div id="body">
    <van-nav-bar
      title="修改密码"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">
      <van-field
        v-model="user.urPassword"
        name="old"
        label="旧密码"
        placeholder="请输入旧密码"
      />
      <van-field
        v-model="user.newPassword"
        type="text"
        name="newPassword"
        label="密码"
        placeholder="请再输入新密码"
      />
      <van-field
        v-model="user.newpass2"
        type="text"
        name="newpass2"
        label="密码"
        placeholder="请再次输入新密码"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import api from "@/api/index";
export default {

  data() {
    return {
      user: {
        urPassword: "",
        newPassword: "",
        urId: localStorage.getItem("tokenlo"),
      },
    };
  },
  methods: {
    onSubmit(values) {
      if (values.newPassword == values.newpass2) {
        api.password(this.user).then((res) => {
            this.$dialog({
            message: res.data.message,
          });
        });
      } else {
        alert("两次输入的密码不一致哦");
      }
    },
    onClickLeft() {
      this.$router.go(-1);
    },
  },
};
</script>

<style>
</style>